<!--
 * @Author: Allen
 * @Date: 2021-01-12 16:24:26
 * @Description: 抱怨身处黑暗，不如提灯前行。愿你在自己存在的地方，成为一束光，照亮世界的一角
 * @LastEditTime: 2021-01-12 18:58:50
 * @LastEditors: Allen
 * @FilePath: \WMS\src\views\WMS\inStorageManage\ArrivalNoteQuery\remarks.vue
 * @Additional: 附加类容
-->

<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="到货单明细查询"
      :visible.sync="curPopupsVisible"
      width="800px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'到货单结案'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <div class="filter-container filter-params">
        <el-row :gutter="26">
          <component
            v-for="comp in tableComponents.filter(o => o.isMust === true)"
            :ref="comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey"
            :validrule="comp.validrule"
            :key="comp.compKey"
            :codeField="comp.codeField"
            :textField="comp.textField"
            :popupsKey="comp.compKey"
            :is="comp.component"
            :code="formField[comp.codeField]"
            :text="formField[comp.textField]"
            @changeCode="getComponentCode"
            @focusCode="getFocusCode"
            :disabled="comp.disabled"
            :isRequire="comp.isRequire"
            :span="comp.span || 8"
            :isMul="comp.isMul"
            :labelName="comp.labelName"
            :lookuptype="comp.lookuptype"
            :options="comp.options"
            :dateOptionsType="comp.dateOptionsType"
            :dataToObject="comp.dataToObject"
            :readonly="comp.readonly"
            :placeholder="comp.placeholder"
          ></component>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-for="comp in tableButtons"
          :key="comp.compKey"
          :type="comp.type"
          @click="comp.clickEvent"
        >{{ comp.text }}</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { onStockApi } from "@/api/wms/onStock";
import { formMixins } from "@/components/wms/mixins/formMixins";
import request from "@/utils/request";
export default {
  name: "Remarkss",
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [formMixins, valueObjectMixins],
  props: {
    remarkCode: {
      type: String,
      default: ""
    },
    remarkJson: {
      type: Object,
      default: {}
    },
    isdetail: {
      type: Boolean,
      default: false
    }
  },
  components: {
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  created() {},
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: onStockApi.queryarrivald, //到货单明细查询
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.endCase(),
          text: "保存" //"保存"
        },
        {
          compKey: "btnKey2",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置" //"重置"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "结案备注",
          codeField: "FINAL_REMARK",
          component: () => import("@/components/wms/textareaInput"),
          type: "inputText",
          isMust: true,
          span: 24,
          isRequire: true
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        FINAL_REMARK: ""
      },
      handleTableRowData: {
        value: "PARTNER_CODE",
        text: "PARTNER_SHORT_NAME"
      }
    };
  },
  methods: {
    endCase() {
      this.$utils.validataMoth(this, "validpopup");
      if (this.valid) {
        request({
          url: "/mp/wm/vl/warehouse/arrival/finalcase.do",
          method: "post",
          data: {
            ARRIVAL_CODE: this.remarkCode
              ? this.remarkCode
              : this.remarkJson.ARRIVAL_CODE,
            FINAL_REMARKL: this.formField.FINAL_REMARK
          }
        }).then(res => {
          if (res.result == 1) {
            this.$message({
              type: "success",
              message: "结案完成！"
            });
            this.$emit("queryTab");
          } else {
            this.$message({
              type: "success",
              message: res.msg
            });
          }
          this.curPopupsVisible = false;
        });
      }
    }
  }
};
</script>
